package ObjGitRequest

import (
	"arabApi/app/api/requests"
	"arabApi/app/api/requests/CRequest"
	"github.com/gin-gonic/gin"
	"github.com/thedevsaddam/govalidator"
)

type GitBranch struct {
	ID     int64  `json:"id" form:"id"`
	ObId   int64  `gorm:"column:ob_id" db:"ob_id" json:"ob_id" form:"ob_id" valid:"ob_id"` //  项目id
	Desc   string `gorm:"column:desc" db:"desc" json:"desc" form:"desc" valid:"desc"`      //  描述
	Branch string `gorm:"column:branch" db:"branch" json:"branch" form:"branch"`           //  分支
	Step   int64  `gorm:"column:step" db:"step" json:"step" form:"step"`                   //  第几步了 1 初始 2 测试环境 3 开发环境 4 正式环境
	CRequest.Cpage
}

func CheckGitObjBranch(data interface{}, c *gin.Context) string {
	// 自定义验证规则
	rules := govalidator.MapData{
		"ob_id": []string{"required"},
		"desc":  []string{"required"},
	}
	// 自定义验证出错时的提示
	messages := govalidator.MapData{
		"ob_id": []string{
			"required:项目ID不能为空",
		},
		"desc": []string{
			"required:分支描述不能为空",
		},
	}

	errs := requests.Validate1(data, rules, messages)
	return requests.GetOneErr(errs)
}
